package com.oracle.controller;

import com.oracle.pojo.Menu;
import com.oracle.service.MenuService;
import com.oracle.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
public class MenuController {
    @Autowired
    private MenuService menuService;
    @Autowired
    private RoleService roleService;
    @RequestMapping("comm")
    public String comm(){
        return "/admin/commList";
    }
    @RequestMapping("roleS")
    public String roleS(){
        return "/admin/role";
    }
    @RequestMapping("menu")
    @ResponseBody
    public Map<String,Object> findMenuByPid(Integer pid){
        List<Menu> menus = menuService.findMenuByPid(pid);
        Map<String,Object> res = new HashMap<String,Object>();
        Map<String,Object> r = new HashMap<String,Object>();
        r.put("children",menus);
        res.put("code",100);
        res.put("msg","菜单获取成功");
        res.put("extend",r);
        return res;
    }
    @RequestMapping("menulist")
    @ResponseBody
    public Object menuList(){
        /*return menuService.findMenuByPid(pid);*/
        return roleService.findAll();
    }

}
